package gunfire.relics;

import basemod.abstracts.CustomRelic;
import com.badlogic.gdx.graphics.Texture;
import com.evacipated.cardcrawl.mod.stslib.relics.ClickableRelic;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.helpers.PowerTip;
import com.megacrit.cardcrawl.relics.AbstractRelic;
import com.megacrit.cardcrawl.rooms.AbstractRoom;
import com.megacrit.cardcrawl.rooms.ShopRoom;
import com.megacrit.cardcrawl.shop.Merchant;
import gunfire.GunfireMod;
import gunfire.util.TextureLoader;

import static gunfire.GunfireMod.makeRelicOutlinePath;
import static gunfire.GunfireMod.makeRelicPath;

public class RefreshAddict extends CustomRelic implements ClickableRelic {

    public static final String ID = GunfireMod.makeID("RefreshAddict");
    private static final Texture IMG = TextureLoader.getTexture(makeRelicPath("RefreshAddict.png"));
    private static final Texture OUTLINE = TextureLoader.getTexture(makeRelicOutlinePath("blank.png"));

    public RefreshAddict() {
        super(ID, IMG, OUTLINE, RelicTier.SHOP, LandingSound.CLINK);
        this.counter = 25;
    }

    @Override
    public void obtain() {
        super.obtain();
        this.description = DESCRIPTIONS[0] + DESCRIPTIONS[1] + this.counter + DESCRIPTIONS[2];
        this.tips.clear();
        this.tips.add(new PowerTip(this.name, this.description));
        this.initializeTips();
    }

    @Override
    public void onEnterRoom(AbstractRoom room) {
        if (room instanceof ShopRoom) {
            this.flash();
            this.pulse = true;
        } else {
            this.pulse = false;
        }
    }

    @Override
    public void onRightClick() {
        if(AbstractDungeon.getCurrRoom() instanceof ShopRoom && AbstractDungeon.player.gold >= this.counter){
            AbstractDungeon.player.loseGold(this.counter);
            this.counter += 25;
            this.description = DESCRIPTIONS[0] + DESCRIPTIONS[1] + this.counter + DESCRIPTIONS[2];
            this.tips.clear();
            this.tips.add(new PowerTip(this.name, this.description));
            this.initializeTips();
            ((ShopRoom) AbstractDungeon.getCurrRoom()).merchant = new Merchant();
        }
    }

    @Override
    public String getUpdatedDescription() {
        return DESCRIPTIONS[0];
    }

    @Override
    public AbstractRelic makeCopy() {
        return new RefreshAddict();
    }
}
